<template>
  <div class="uipop">
    <div class="layer"></div>
    <div class="show_pop bdradius">
      <div class="poptitle">
        <span class="fs14_bold">操作</span>
      </div>
      <div class="popdis fs18">
        <div class="popdis">
          <div class="con">
            <label v-if="getDialogs.step == 2">质检结果:</label>
            <ul v-if="getDialogs.step == 2" class="radio">
              <li id="isQualified_0" @click="isQualifieds(0)" :class='{"selected" : isQualified == 0}'>合格</li>
              <li id="isQualified_1" @click="isQualifieds(1)" :class='{"selected" : isQualified == 1}'>不合格</li>
            </ul>
            <label>评价:</label>
            <textarea
              id="_contentQuality"
              v-model="content"
              placeholder="请输入评价"
              style="resize: none; height: 90px;width: 290px;"
            ></textarea>
          </div>
        </div>
      </div>
      <div class="btngroup">
        <a class="yes" @click="issure">确定</a>
        <a class="no" @click="cancel">取消</a>
      </div>
    </div>
  </div>
</template>
<script>
import { mapGetters } from "vuex";
export default {
  name: "dialogs",
  data() {
    return {
      isQualified: 0,
      content: ""
    };
  },
  computed:{
    ...mapGetters(["getDialogs"]),
  },
  methods: {
    isQualifieds(n){
      this.isQualified = n;
    },
    issure() {
      if (this.content.length > 500 || this.content.length < 4) {
        this.$message("请输入规定范围文字个数4~500");
        return false;
      }
      this.$MessageBox.confirm("任务已完成，确认提交？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.Assapi.submitTask(
            self.getDialogs.markTaskId,
            JSON.stringify({
              isQualified: this.isQualified,
              evaluate: this.content
            }),
            function() {
              this.$message("提交成功...");
              this.$emit(this.getDialogs.clearInterval);
            }
          );
        })
        .catch(error => {
          this.$message.error(error);
        });
      this.$emit(this.getDialogs.isKeydownPrepare);
    },
    cancel() {
      this.$store.state.dialogs.status = false;
      this.$emit(this.getDialogs.isKeydownPrepare);
    }
  }
};
</script>